﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gunningine
{
    public abstract class Mesh : RenderResource
    {
        public abstract class Frame {}

        /// <summary>
        /// Animation, contains:
        /// list of frames
        /// </summary>
        public abstract class Animation
        {
            public List<Frame> frames = new List<Frame>();

            protected abstract Frame AddFrameImpl();

            /// <summary>
            /// Add frame.
            /// </summary>
            /// <returns></returns>
            public Frame AddFrame()
            {
                Frame frame = AddFrameImpl();

                this.frames.Add(frame);
                return frame;
            }
        }

        /// <summary>
        /// Animations.
        /// </summary>
        public Dictionary<string, Animation> animations = new Dictionary<string, Animation>();

        public Dictionary<string, Animation> Animations
        {
            get
            {
                return this.animations;
            }
        }

        public int NumTriangles { get; set; }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model"></param>
        public Mesh(ModelResource model)
        {
        }

        protected abstract Animation AddAnimationImpl();

        /// <summary>
        /// Add a named animation.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Animation AddAnimation(string name)
        {
            Animation anim = AddAnimationImpl();
            this.animations[name] = anim;

            return anim;
        }

        public abstract void Render(string animName, int frame);
    }
}
